﻿
'http://www.ietf.org/rfc/rfc2109.txt
'http://www.ietf.org/rfc/rfc2965.txt

Public Module rfc2109

    Public Function generateCookie(ByVal namevalue As String) As String
        If Not isemptystring(namevalue) Then
            Dim rtn As String = Nothing
            'cannot work on FF if there is not a blank after ;, so ...
            rtn = namevalue + network.cookieSeparator + character.blank
            Return rtn
        Else
            Return Nothing
        End If
    End Function

    Public Function generateCookie(ByVal name As String, ByVal value As String) As String
        If Not isemptystring(name) Then
            Return generateCookie(name + network.cookieNameValueSeparator + value)
        Else
            Return Nothing
        End If
    End Function

    Public Function generateCookie(ByVal domain As String, ByVal path As String, ByVal name As String, _
                                   ByVal value As String, ByVal expires As DateTime) As String
        Dim rtn As String = Nothing
        rtn = generateCookie(name, value)
        If Not isemptystring(domain) Then
            rtn += generateCookie(network.http.headers.setcookie.domain, domain)
        End If
        If Not isemptystring(path) Then
            rtn += generateCookie(network.http.headers.setcookie.path, path)
        End If
        If expires > DateTime.MinValue Then
            rtn += generateCookie(network.http.headers.setcookie.expires, toGMTTime(expires))
            rtn += generateCookie(network.http.headers.setcookie.max_age(expires.Ticks() - Now.Ticks()))
        End If

        Return rtn
    End Function
End Module
